package MiniSpanTree;

import Graph.AdMatrix.GraphKind;
import Graph.AdMatrix.MGraph;

public class MinMain {
    private static final int INFINITY = Integer.MAX_VALUE;


    public static void main(String[] args) throws Exception {
        Object vex1[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
        int[][] arcs1 = {{0, INFINITY, INFINITY, 3, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY},
                {INFINITY, 0, 4, INFINITY, INFINITY, INFINITY, INFINITY, 5, INFINITY, INFINITY},
                {INFINITY, 4, 0, INFINITY, 6, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY},
                {3, INFINITY, INFINITY, 0, INFINITY, INFINITY, 2, INFINITY, INFINITY, INFINITY},
                {INFINITY, INFINITY, 6, INFINITY, 0, 1, INFINITY, INFINITY, INFINITY, INFINITY},
                {INFINITY, INFINITY, INFINITY, INFINITY, 1, 0, INFINITY, INFINITY, INFINITY, INFINITY},
                {INFINITY, INFINITY, INFINITY, 2, INFINITY, INFINITY, 0, 7, 8, 9},
                {INFINITY, 5, INFINITY, INFINITY, INFINITY, INFINITY, 7, 0, INFINITY, INFINITY},
                {INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 8, INFINITY, 0, INFINITY},
                {INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, INFINITY, 9, INFINITY, INFINITY, 0},

        };


        System.out.println("最小生成树：  ");
        MGraph G0 = new MGraph(GraphKind.UDN, 10, 9, vex1, arcs1);
        Object[][] tree0 = new MiniSpanTree().PRIM(G0, "A");
        for (int i = 0; i < tree0.length; i++)
            System.out.println(tree0[i][0] + "-" + tree0[i][1]);
    }
}